﻿@{
    ViewData["Title"] = "添加广告位";
    Layout = "~/Areas/Manager/Views/Shared/_Layout.cshtml";
}
<div class="layui-bg" style="padding-bottom:80px;">
    <form class="layui-form" style="padding: 20px 30px 0 0;">
        <div class="layui-form-item">
            <label class="layui-form-label">显示类型</label>
            <div class="layui-input-block">
                <select id="ShowType" name="ShowType" lay-verify="required" lay-filter="Select">
                    <option value="0">纵向平铺</option>
                    <option value="1">横向平铺</option>
                    <option value="2">层叠显示</option>
                    <option value="3">交替显示</option>
                    <option value="4">自定义广告代码</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">广告位名称</label>
            <div class="layui-input-block">
                <input type="text" name="AdvPositionName" class="layui-input" lay-verify="required">
            </div>
        </div>
        <div class="layui-form-item" style="display:none" id="RepeatColumns">
            <label class="layui-form-label">行显示个数</label>
            <div class="layui-input-block">
                <input type="text" name="RepeatColumns" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item" style="display:none" id="AdvHtml">
            <label class="layui-form-label">广告位内容</label>
            <div class="layui-input-block">
                <textarea name="AdvHtml" class="layui-textarea" style="height:70px;width:100%"></textarea>
            </div>
        </div>
        <div class="layui-form-item" pane="">
            <div class="layui-input-block" id="IsOneBox">
                <input type="checkbox" lay-skin="primary" title="循环显示" lay-filter="isOne">
                <input type='hidden' name='TimeInterval' placeholder='循环间隔' id="temporaryInput" class='temporaryInput layui-input' style='display:inline-block;width:75px;' />
                <input type="hidden" name="IsOne" id="IsOne" value=false />
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="add" id="submit" type="button" >保存</button>
                <button id="close" type="button" class="layui-btn layui-btn-primary">关闭</button>
            </div>
        </div>
    </form>
</div>
@section scriptsfeet
    {
    <script type="text/javascript">
        
        layui.config({
            base: '/layuiadmin/' //自定义模块路径
        }).use(['form', 'layer', 'sykjwh'], function () {
            var $ = layui.$, form = layui.form, sykjwh = layui.sykjwh;
            
            form.on('checkbox(isOne)', function (data) {
                $("#temporaryInput").attr("type", "hidden");
                if (data.elem.checked) {//判断复选框是否被选中
                    $("#IsOne").val(true);//如果选中则修改IsOne的value为true
                    $("#temporaryInput").attr("type", "text");
                } else {
                    $("#IsOne").val(false);
                }
            });  

            form.on('select(Select)', function (data) {
                if (data.value == 1) {
                    $("#RepeatColumns").show();
                    $("#AdvHtml").hide();
                } else if (data.value == 4) {
                    $("#RepeatColumns").hide();
                    $("#AdvHtml").show();
                }else {
                    $("#RepeatColumns").hide();
                    $("#AdvHtml").hide();
                }
            });

            $("#close").click(function () {
                sykjwh.close();
            });

            form.on('submit(add)', function (obj) {
                console.log(obj.field);
                //保存
                sykjwh.save('@Url.Action("AdpositionAdd", "ad", new { area = Constant.AREAMANAGER })', obj.field);
            });

        });
    </script>
}
